//
//  ViewController.m
//  iOSDeme
//
//  Created by wxf on 2024/8/12.
//

#import "ViewController.h"
#import "AddViewController.h"
#import "TestMoveViewController.h"
#import "TestUILabelViewController.h"
#import "TestUIViewViewController.h"
#import "TestUIButtonViewController.h"
#import "TestUITableViewViewController.h"
#import "TestUIScrollViewViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    NSLog(@"ViewController viewDidLoad");
    
    //[self setupButton];
//    [self initMainList ];
    [self initMainList1];
    
}

-(void)initMainList1{
    self.view.backgroundColor = [UIColor yellowColor];
    UIStackView *stackView = [[UIStackView alloc] initWithFrame:CGRectMake(20, 100, self.view.bounds.size.width - 40, self.view.bounds.size.height-200)];
    stackView.axis = UILayoutConstraintAxisVertical; // 设置堆叠方向为垂直
    stackView.distribution = UIStackViewDistributionFillEqually; // 子视图等宽填充
    stackView.alignment = UIStackViewAlignmentFill; // 子视图填充整个stackView
    stackView.spacing = 10; // 子视图之间的间距
    stackView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:stackView];
    
    
    UIButton *btn0 = [[UIButton alloc] init];
    btn0.backgroundColor = [UIColor grayColor];
    [btn0 setTitle:@"UIView" forState:UIControlStateNormal];
    [btn0 addTarget:self action:@selector(clickGoToTestUIView) forControlEvents:UIControlEventTouchUpInside];
    [stackView addArrangedSubview:btn0];
    
    
    
    UIButton *btn1 = [[UIButton alloc] init];
    btn1.backgroundColor = [UIColor redColor];
    [btn1 setTitle:@"UILabel" forState:UIControlStateNormal];
    [btn1 addTarget:self action:@selector(clickGoToTestUILabel) forControlEvents:UIControlEventTouchUpInside];
    [stackView addArrangedSubview:btn1];
    
    
    UIButton *btn2 = [[UIButton alloc] initWithFrame:CGRectMake(100, 200, 90, 40)];
    btn2.backgroundColor = [UIColor grayColor];
    [btn2 setTitle:@"UIButton" forState:UIControlStateNormal];
    [btn2 addTarget:self action:@selector(clickGoToTestUIButton) forControlEvents:UIControlEventTouchUpInside];
    [stackView addArrangedSubview:btn2];
    
    
    UIButton *btnUITableView = [[UIButton alloc] initWithFrame:CGRectMake(200, 200, 100, 40)];
    btnUITableView.backgroundColor = [UIColor grayColor];
    [btnUITableView setTitle:@"UITableView" forState:UIControlStateNormal];
    [btnUITableView addTarget:self action:@selector(clickGoToTestUITableView) forControlEvents:UIControlEventTouchUpInside];
    [stackView addArrangedSubview:btnUITableView];
    
    
    UIButton *btnUIScrollView = [[UIButton alloc] initWithFrame:CGRectMake(200, 200, 100, 40)];
    btnUIScrollView.backgroundColor = [UIColor grayColor];
    [btnUIScrollView setTitle:@"UIScrollView" forState:UIControlStateNormal];
    [btnUIScrollView addTarget:self action:@selector(clickGoToTestUIScrollView) forControlEvents:UIControlEventTouchUpInside];
    [stackView addArrangedSubview:btnUIScrollView];
    
    
    
    UIButton *btn3 = [[UIButton alloc] initWithFrame:CGRectMake(100, 250, 100, 40)];
    btn3.backgroundColor = [UIColor grayColor];
    [btn3 setTitle:@"测试加法" forState:UIControlStateNormal];
    [btn3 addTarget:self action:@selector(addGoToClick) forControlEvents:UIControlEventTouchUpInside];
    [stackView addArrangedSubview:btn3];
    
    
    
    UIButton *btn4 = [[UIButton alloc] initWithFrame:CGRectMake(100, 300, 100, 40)];
    btn4.backgroundColor = [UIColor grayColor];
    [btn4 setTitle:@"组件移动" forState:UIControlStateNormal];
    [btn4 addTarget:self action:@selector(clickGoToTestMove) forControlEvents:UIControlEventTouchUpInside];
    [stackView addArrangedSubview:btn4];
    
}

//2024-08-25-----------------------------------
//页面跳转控制
-(void)initMainList{
    self.view.backgroundColor = [UIColor redColor];
    
    UIButton *btn0 = [[UIButton alloc] initWithFrame:CGRectMake(100, 100, 90, 40)];
    btn0.backgroundColor = [UIColor grayColor];
    [btn0 setTitle:@"UIView" forState:UIControlStateNormal];
    [btn0 addTarget:self action:@selector(clickGoToTestUIView) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn0];
    
    
    UIButton *btn1 = [[UIButton alloc] initWithFrame:CGRectMake(100, 150, 90, 40)];
    btn1.backgroundColor = [UIColor grayColor];
    [btn1 setTitle:@"UILabel" forState:UIControlStateNormal];
    [btn1 addTarget:self action:@selector(clickGoToTestUILabel) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn1];
    
    UIButton *btn2 = [[UIButton alloc] initWithFrame:CGRectMake(100, 200, 90, 40)];
    btn2.backgroundColor = [UIColor grayColor];
    [btn2 setTitle:@"UIButton" forState:UIControlStateNormal];
    [btn2 addTarget:self action:@selector(clickGoToTestUIButton) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn2];
    
    UIButton *btnUITableView = [[UIButton alloc] initWithFrame:CGRectMake(200, 200, 100, 40)];
    btnUITableView.backgroundColor = [UIColor grayColor];
    [btnUITableView setTitle:@"UITableView" forState:UIControlStateNormal];
    [btnUITableView addTarget:self action:@selector(clickGoToTestUITableView) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btnUITableView];
    
    
    
    UIButton *btn3 = [[UIButton alloc] initWithFrame:CGRectMake(100, 250, 100, 40)];
    btn3.backgroundColor = [UIColor grayColor];
    [btn3 setTitle:@"测试加法" forState:UIControlStateNormal];
    [btn3 addTarget:self action:@selector(addGoToClick) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:btn3];
    
    
    
    UIButton *btn4 = [[UIButton alloc] initWithFrame:CGRectMake(100, 300, 100, 40)];
    btn4.backgroundColor = [UIColor grayColor];
    [btn4 setTitle:@"组件移动" forState:UIControlStateNormal];
    [btn4 addTarget:self action:@selector(clickGoToTestMove) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:btn4];
    
    
    
}

-(void)addGoToClick{
    NSLog(@"ViewController addGoToClick");
    NSLog(@"ViewController addGoToClick navigationController =%@" , self.navigationController);
    //跳转另一个页面
    
    AddViewController *add = [[AddViewController alloc] init];
    
    [self.navigationController pushViewController:add animated:YES];
}

-(void)clickGoToTestUIView{
    NSLog(@"ViewController clickGoToTestUIView");
    NSLog(@"ViewController clickGoToTestUIView navigationController =%@" , self.navigationController);
    //跳转另一个页面
    TestUIViewViewController *controller = [[TestUIViewViewController alloc] init];
    
    [self.navigationController pushViewController:controller animated:YES];
}

-(void)clickGoToTestUILabel{
    NSLog(@"ViewController clickGoToTestUILabel");
    NSLog(@"ViewController clickGoToTestUILabel navigationController =%@" , self.navigationController);
    //跳转另一个页面
    TestUILabelViewController *controller = [[TestUILabelViewController alloc] init];
    
    [self.navigationController pushViewController:controller animated:YES];
}

-(void)clickGoToTestUIButton{
    NSLog(@"ViewController clickGoToTestUIButton");
    NSLog(@"ViewController clickGoToTestUIButton navigationController =%@" , self.navigationController);
    //跳转另一个页面
    TestUIButtonViewController *controller = [[TestUIButtonViewController alloc] init];
    [self.navigationController pushViewController:controller animated:YES];
}
    
-(void)clickGoToTestMove{
    NSLog(@"ViewController clickGoToTestMove");
    NSLog(@"ViewController clickGoToTestMove navigationController =%@" , self.navigationController);
    //跳转另一个页面

    TestMoveViewController *controller = [[TestMoveViewController alloc] init];
    
    [self.navigationController pushViewController:controller animated:YES];
}

-(void)clickGoToTestUITableView{
    TestUITableViewViewController *controller = [[TestUITableViewViewController alloc] init];
    [self.navigationController pushViewController:controller animated:YES];
}

-(void)clickGoToTestUIScrollView{
    TestUIScrollViewViewController *controller = [[TestUIScrollViewViewController alloc] init];
    [self.navigationController pushViewController:controller animated:YES];
}

@end
